﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test6-4-2.aspx.cs" Inherits="Web_Project.test6_4_2" %>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>GridView Example</title>
    <style type="text/css">
        .selected-row 
        {
            background-color: yellow;
        }
        .grid-container {
            display: flex; /* 使用 Flexbox 布局 */
            justify-content: space-between; /* 子元素之间的间隔 */
            margin-top: 10px; /* 添加顶部外边距 */
        }
        .grid-item {
            flex: 1; /* 允许元素填充可用空间 */
            min-width: 45%; /* 设置最小宽度 */
            margin-right: 10px; /* 设置右边距 */
        }
        .grid-item:last-child {
            margin-right: 0; /* 最后一个元素不设置右边距 */
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:mfd_severConnectionString %>" SelectCommand="SELECT * FROM [Cartoon]"></asp:SqlDataSource>
            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ct_id" DataSourceID="SqlDataSource1">
                <Columns>
                    <asp:BoundField DataField="ct_id" HeaderText="编号" ReadOnly="True" SortExpression="ct_id" />
                    <asp:BoundField DataField="ct_name" HeaderText="动画片名" SortExpression="ct_name" />
                    <asp:BoundField DataField="ct_au" HeaderText="作者" SortExpression="ct_au" />
                    <asp:TemplateField HeaderText="时间" SortExpression="ct_time">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("ct_time") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" ForeColor="Red" Text='<%# Bind("ct_time") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="ct_dq" HeaderText="地区" SortExpression="ct_dq" />
                </Columns>
            </asp:GridView>
            <br />

            <div style="width:100%;">
                <div style="float:left; margin-right: 10px;">
                    <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" AutoGenerateSelectButton="True" DataKeyNames="ct_CategoryId" DataSourceID="srcCartoonCategories">
                        <Columns>
                            <asp:BoundField DataField="ct_CategoryId" HeaderText="编号" InsertVisible="False" ReadOnly="True" SortExpression="ct_CategoryId" />
                            <asp:BoundField DataField="Name" HeaderText="种类" SortExpression="Name" />
                        </Columns>
                        <SelectedRowStyle CssClass="selected-row" />
                    </asp:GridView>
                </div>
                <div style="float:left;">
                    <asp:GridView ID="GridView3" runat="server" AutoGenerateColumns="False" DataSourceID="scrCartoon">
                        <Columns>
                            <asp:BoundField DataField="ct_name" HeaderText="动画名" SortExpression="ct_name" />
                            <asp:BoundField DataField="ct_au" HeaderText="作者" SortExpression="ct_au" />
                        </Columns>
                    </asp:GridView>
                </div>
            </div>
            <div style="clear: both;"></div>

            <div class="grid-container">
                <div class="grid-item">
                    <asp:GridView ID="GridView4" runat="server" AutoGenerateColumns="False" DataKeyNames="ct_CategoryId" DataSourceID="SqlDataSource2">
                        <Columns>
                            <asp:BoundField DataField="ct_CategoryId" HeaderText="ct_CategoryId" InsertVisible="False" ReadOnly="True" SortExpression="ct_CategoryId" />
                            <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:Button ID="Button1" runat="server" CommandName="Select" Text="选择" CausesValidation="False" />
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
                </div>
                <div class="grid-item">
                    <asp:GridView ID="GridView5" runat="server" AutoGenerateColumns="False" DataKeyNames="ct_id" DataSourceID="SqlDataSource3">
                        <Columns>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    ct_id:<asp:Label ID="Label2" runat="server" Text='<%# Eval("ct_id") %>'></asp:Label><br />
                                    ct_name:<asp:Label ID="Label3" runat="server" Text='<%# Eval("ct_name") %>'></asp:Label><br />
                                    ct_time:<asp:Label ID="Label4" runat="server" Text='<%# Eval("ct_time") %>'></asp:Label><br />
                                    ct_au:<asp:Label ID="Label5" runat="server" Text='<%# Eval("ct_au") %>'></asp:Label><br />
                                    ct_dq:<asp:Label ID="Label6" runat="server" Text='<%# Eval("ct_dq") %>'></asp:Label><br />
                                    ct_com:<asp:Label ID="Label7" runat="server" Text='<%# Eval("ct_com") %>'></asp:Label><br />
                                    ct_CategoryId:<asp:Label ID="Label8" runat="server" Text='<%# Eval("ct_CategoryId") %>'></asp:Label><br />
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
                </div>
            </div>

            <asp:SqlDataSource ID="srcCartoonCategories" runat="server" ConnectionString="<%$ ConnectionStrings:mfd_severConnectionString %>" SelectCommand="SELECT * FROM [ctCategory]"></asp:SqlDataSource>
            <asp:SqlDataSource ID="scrCartoon" runat="server" ConnectionString="<%$ ConnectionStrings:mfd_severConnectionString %>" SelectCommand="SELECT * FROM [Cartoon] WHERE ([ct_CategoryId] = @ct_CategoryId)">
                <SelectParameters>
                    <asp:ControlParameter ControlID="GridView2" Name="ct_CategoryId" PropertyName="SelectedValue" Type="Int32" />
                </SelectParameters>
            </asp:SqlDataSource>
            <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:mfd_severConnectionString %>" SelectCommand="SELECT * FROM [ctCategory]"></asp:SqlDataSource>
            <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:mfd_severConnectionString %>" SelectCommand="SELECT * FROM [Cartoon] WHERE ([ct_CategoryId] = @ct_CategoryId)">
                <SelectParameters>
                    <asp:ControlParameter ControlID="GridView4" Name="ct_CategoryId" PropertyName="SelectedValue" Type="Int32" />
                </SelectParameters>
            </asp:SqlDataSource>
            <br />
            <br />
            <br />
            请输入名称：<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
            <asp:Button ID="Button2" runat="server" CommandName="Select" Text="查询" />
            <asp:Button ID="Button3" runat="server" OnClick="Button3_Click" Text="重置" />
            <br />
            <asp:GridView ID="GridView6" runat="server" AutoGenerateColumns="False" DataKeyNames="ct_id" DataSourceID="SqlDataSource4">
                <Columns>
                    <asp:BoundField DataField="ct_id" HeaderText="编号" ReadOnly="True" SortExpression="ct_id" />
                    <asp:BoundField DataField="ct_name" HeaderText="动画片名" SortExpression="ct_name" />
                    <asp:BoundField DataField="ct_au" HeaderText="作者" SortExpression="ct_au" />
                    <asp:BoundField DataField="ct_time" HeaderText="时间" SortExpression="ct_time" />
                    <asp:BoundField DataField="ct_dq" HeaderText="地区" SortExpression="ct_dq" />
                </Columns>
            </asp:GridView>
            <br />
            <asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:mfd_severConnectionString %>" SelectCommand="SELECT * FROM [Cartoon] WHERE ([ct_name] LIKE '%' + @ct_name + '%')">
                <SelectParameters>
                    <asp:ControlParameter ControlID="TextBox2" Name="ct_name" PropertyName="Text" Type="String" />
                </SelectParameters>
            </asp:SqlDataSource>
        </div>
    </form>
</body>
</html>